package com.ccsoft.atools.controller;


import com.ccsoft.atools.model.CashType;
import com.ccsoft.atools.service.CashTypeService;
import com.ccsoft.atools.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@CrossOrigin
@RestController
@RequestMapping("/cashType")
public class CashTypeController {

    @Autowired
    private CashTypeService service;

    @DeleteMapping("/deleteByPrimaryKey/{iid}")
    public JsonResult deleteByPrimaryKey(@PathVariable java.lang.Integer iid) {
        return JsonResult.ok(service.deleteByPrimaryKey(iid));
    }

    @GetMapping("/selectByPrimaryKey/{iid}")
    public JsonResult selectByPrimaryKey(@PathVariable java.lang.Integer iid) {
        return JsonResult.ok(service.selectByPrimaryKey(iid));
    }

    @GetMapping("/selectAll")
    public JsonResult selectAll() {
        return JsonResult.ok(service.selectAll());
    }


    @PostMapping("/insert")
    public JsonResult insert(@RequestBody CashType record) {
        return JsonResult.ok(service.insertSelective(record));
    }

    @PutMapping("/update")
    public JsonResult update(@RequestBody CashType record) {
        return JsonResult.ok(service.updateByPrimaryKey(record));
    }

    @GetMapping("/selectByType/{colpay}")
    public JsonResult selectByType(@PathVariable String colpay) {
        return JsonResult.ok(service.selectByType(colpay));
    }

    @PostMapping("/list")
    public JsonResult list(@RequestBody Map<String, Object> params) {
        return JsonResult.ok(service.selectAll());
    }


}